package com.ddrj.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ddrj.entity.DiaryEntity;
import com.ddrj.service.DiaryService;

@Controller
@RequestMapping("/")
public class IndexController {
	
	@Autowired
	DiaryService diaryService;	
	
	
	
	
	@RequestMapping("/")
    public String index() {
        return "redirect:/index.html";
    }

	
	@RequestMapping("/index.html")
    public String list(Model model,String token) {
		List<DiaryEntity> diary = diaryService.list(); //全部日记
		List<DiaryEntity> recomDiary = diaryService.recomDiaryLlist();//推荐日记
		List<DiaryEntity> newDiary = diaryService.newDiaryLlist();//最新日记
        model.addAttribute("diary", diary);
        model.addAttribute("recomDiary", recomDiary);
        model.addAttribute("newDiary", newDiary);
//        System.out.println(diary);
        return "index";
    }
	
	@RequestMapping("/about.html")
    public String about(Model model,String token) {
        model.addAttribute("", null);
        return "about";
    }
	
	@RequestMapping("/contact.html")
    public String contact(Model model,String token) {
        model.addAttribute("", null);
        return "contact";
    }
	
	@RequestMapping("/single.html")
    public String single(Model model,String token) {
        model.addAttribute("", null);
        return "single";
    }

}
